<ui:composition template="/admin/templates/ui2.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:composite="http://java.sun.com/jsf/composite/primefaces"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:sec="http://www.springframework.org/security/facelets/tags">


    <ui:define name="content">
    
    <div class="entry">
    	<p:toolbar>
            <p:toolbarGroup>
	            <h:outputLabel style="padding-left: 15px;" value="#{commonMsg.currentPositionLabel}#{userMsg.userManagerLabel}"></h:outputLabel>
            </p:toolbarGroup>
            <p:toolbarGroup align="right">
	            <p:separator />  
	            <p:button value="#{userMsg.addUserLabel}" outcome="/admin/user/addUser"></p:button>
            </p:toolbarGroup>
        </p:toolbar>
        
        <h:form id="form"> 
        	<p:spacer></p:spacer> 
                <p:panel id="filters">
                    <p:inputText id="searchId" value="#{userList.example.id}"></p:inputText>
                    <p:inputText id="searchTitle" value="#{userList.example.username}"></p:inputText>
                    <br/>
                    <p:inputText id="mobileNumber" value="#{userList.example.mobileNumber}"></p:inputText>
                    <p:inputText id="email" value="#{userList.example.email}"></p:inputText>
                    
                    <p:commandButton update="dataTable" process="filters"
                        value="#{commonMsg.searchLabel}"></p:commandButton>
                    <p:button value="#{commonMsg.resetLabel}" onclick="location.reload();return;"></p:button>
                </p:panel>
                <p:watermark for="searchId" value="#{commonMsg.IDLabel}" />  
                <p:watermark for="searchTitle" value="#{userMsg.username}"></p:watermark>
                <p:watermark for="mobileNumber" value="手机号码"></p:watermark>
                <p:watermark for="email" value="邮箱"></p:watermark>
            <p:spacer></p:spacer> 

            <p:dataTable lazy="true" id="dataTable" value="#{userList.lazyModel}" var="user" 
                paginator="true" paginatorPosition="bottom" rows="15" rowsPerPageTemplate="15,50,100"
                rowStyleClass="#{user.status != '1'?'disable':''}" sortBy="user.registerTime" sortOrder="descending"
                currentPageReportTemplate="#{commonMsg.pageReportTemplate}"
                paginatorTemplate="#{commonMsg.paginatorTemplate}"
                emptyMessage="#{commonMsg.noResultMsg}" >
<!--                 selection="#{userList.selectedUsers}" -->
                
<!--                 <p:column selectionMode="multiple" style="width:18px" exportable="false"/>  -->
                 
                <p:column sortBy="user.id">
                	<f:facet name="header">
                		<h:outputText value="#{commonMsg.IDLabel}"></h:outputText>
                	</f:facet>
                    <h:outputText  value="#{user.id}"></h:outputText>
                </p:column>
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.username}"></h:outputText>
                	</f:facet>
                    <h:outputText  value="#{user.username}"></h:outputText>
                </p:column>
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.realname}"></h:outputText>
                	</f:facet>
                    <h:outputText  value="#{user.realname}"></h:outputText>
                </p:column>
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.sex}"></h:outputText>
                	</f:facet>
                    <h:outputText value="#{dictUtil.getValue('user_sex',user.sex)}"/>
                </p:column>
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="手机号码"></h:outputText>
                	</f:facet>
                    <h:outputText value="#{user.mobileNumber}"></h:outputText>
                </p:column>
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.email}"></h:outputText>
                	</f:facet>
                    <h:outputText  value="#{user.email}"></h:outputText>
                </p:column>
<!--                 <ui:param name="refers" value="#{motionTrackingList.getMotionTrackingsByWhoFromType(user.id, 'referee')}"></ui:param> -->
                <p:column sortBy="user.registerTime">
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.registerTime}"></h:outputText>
                	</f:facet>
                    <h:outputText value="#{user.registerTime}">
                        <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8"/>
                    </h:outputText>
                </p:column>
                 <p:column>
                	<f:facet name="header">
                		<h:outputText value="角色"></h:outputText>
                	</f:facet>
					<ui:repeat var="role" value="#{user.roles}">
               			<h:outputText value="#{role.name}"></h:outputText>&#160;
               		</ui:repeat>
                </p:column>
                <p:column sortBy="user.status">
                	<f:facet name="header">
                		<h:outputText value="#{userMsg.status}"></h:outputText>
                	</f:facet>
                    <h:outputText value="#{userMsg.stautsEnable}" rendered="#{user.status == '1'}"></h:outputText>
                    <h:outputText style="color:red;" value="#{userMsg.stautsDisable}" rendered="#{user.status == '0'}"></h:outputText>
                </p:column>
                
                <p:column>
                	<f:facet name="header">
                		<h:outputText value="钉钉"></h:outputText>
                	</f:facet>
                    <h:outputText value="已绑定" rendered="#{user.duser.bindStatus eq '1'}"></h:outputText>
                    <h:outputText style="color:red;" value="未绑定" rendered="#{user.duser.bindStatus ne '1'}"></h:outputText>
                </p:column>
                
                <p:column headerText="#{commonMsg.actionLabel}" exportable="false">
                    <h:link value="[ #{commonMsg.editLabel} ]" outcome="/admin/user/userEdit?id=#{user.id}"></h:link> <font color="red"><b>| </b></font>
                    <p:commandLink actionListener="#{userHome.forbid(user.id)}" onstart="return confirm('确认禁用该用户吗？');"  update="dataTable"
						value="[ #{userMsg.forbidLabel} ]" rendered="#{user.status == '1'}" process="@this">
                    </p:commandLink>
                     <p:commandLink actionListener="#{userHome.release(user.id)}" onstart="return confirm('确认解禁该用户吗？');" update="dataTable"
						value="[ #{userMsg.releaseLabel} ]" rendered="#{user.status == '0'}" process="@this">
                    </p:commandLink> 
                    <ui:fragment rendered="#{user.duser.bindStatus == '1'}" >
	                    <font color="red"><b>| </b></font>
	                    <p:commandLink actionListener="#{userHome.unBindDingDing(user.id, true)}" onstart="return confirm('确认解绑钉钉吗？');" update="dataTable"
							value="[ 解绑钉钉 ]" process="@this">
	                    </p:commandLink>
                    </ui:fragment>
                </p:column>
                
               <f:facet name="footer">

						<p:commandButton value="导出Excel" ajax="false">
							<p:dataExporter target="dataTable" type="xls"
								fileName="userList" pageOnly="false"></p:dataExporter>
						</p:commandButton>

					</f:facet>
                
                
            </p:dataTable>
            <p:confirmDialog width="500" id="confirmDialog" widgetVar="confirmDialog" severity="alert" header="#{commonMsg.confirmForbid}" message="#{userMsg.forbidUserInfo}">
                    <p:commandButton id="confirm" value="#{commonMsg.confirmLabel}" process="@this" actionListener="#{userHome.forbid}" oncomplete="confirmDialog.hide()" update="dataTable" style="margin-left:180px;" />  
                    <p:commandButton id="decline" value="#{commonMsg.cancelLabel}" onclick="confirmDialog.hide()" type="button" />
            </p:confirmDialog>
            <p:confirmDialog width="500" id="confirmDialog1" widgetVar="confirmDialog1" severity="alert" header="#{commonMsg.confirmRelease}" message="#{userMsg.releaseUserInfo}">
                    <p:commandButton id="confirm1" value="#{commonMsg.confirmLabel}" process="confirmDialog1" actionListener="#{userHome.release}" oncomplete="confirmDialog1.hide()" update="dataTable" style="margin-left:180px;" />  
                    <p:commandButton id="decline1" value="#{commonMsg.cancelLabel}" onclick="confirmDialog1.hide()" type="button" />
            </p:confirmDialog>
            <script type="text/javascript">  
       		   //<![CDATA[.......
			    function handleLoginRequest(xhr, status, args) {  
			        if(!args.validationFailed && args.sendSuccess) {  
			        	sendMessageDialog.hide();
			        } else {  
			          	jQuery('#form\\:sendMessageDlg').effect("shake", { times:3 }, 100);  
			        }
			    }
       		   
			    function handleLoginRequest_Email(xhr, status, args) {  
			        if(!args.validationFailed && args.sendSuccess) {  
			        	sendEmailDialog.hide();
			        } else {  
			          	jQuery('#form\\:sendEmailDlg').effect("shake", { times:3 }, 100);  
			        }
			    }
			    //]]> 
			</script>  
        
            </h:form>
      </div>
    </ui:define> 
</ui:composition>
